package leetcode;

/**
 * @Classname NumTeams_5369
 * @Author happytaohaha
 * @Date 2020/3/29
 * @Description 统计作战单位数   暴力解法 O(N^3)
 */
public class NumTeams_5369 {

    public static int numTeams(int[] rating) {
        int len = rating.length;
            int result = 0;
            for (int i = 0; i < len - 2; i++) {
                for (int j = i + 1; j < len - 1; j++) {
                    for (int k = j + 1; k < len; k++) {
                        if (rating[i] < rating[j] && rating[j] < rating[k]) {
                            result++;
                        }
                        if (rating[i] > rating[j] && rating[j] > rating[k]) {
                            result++;
                        }
                    }
                }
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(numTeams(new int[]{1,2,3,4}));
    }
}
